package com.hk;

public class OddMagicSquare extends MagicSquare{
	public OddMagicSquare(){
		this(3);
	}
	public OddMagicSquare(int n){
		super(n);
	}
	public void make(){
		int n = magic.length;
		int x = 0;
		int y = n/2;
		magic[x][y] = 1;
		for (int i = 2; i <= n*n; i++) {
			int tempX = x;
			int tempY = y;
			if(x-1<0){
				x = n-1;
			}else{
				x--;
			}
			if(y-1<0){
				y = n-1;
			}else{
				y--;
			}
			if(magic[x][y]!=0){
				x = tempX+1;
				y = tempY;
			}
			magic[x][y] = i;
		}
	}
}
